package com.t14;

/**
 * Created by xuyiwei on 2018/8/7.
 */
interface HasBatteries{}
interface Waterproof{}
interface Shoots{}
class Tony{
    public Tony(){};
    public Tony(int i){};
}
class FancyToy extends Tony implements HasBatteries,Waterproof,Shoots{
    public  FancyToy(){super(1);}
}
public class ToyTest {
    static void printInfo(Class cc){
        System.out.println("Class name: "+cc.getName()+" is interface? ["+cc.isInterface()+"]");
        System.out.println("Simple name: "+cc.getSimpleName()+"");
        System.out.println("Canonical name: "+cc.getCanonicalName());
    }

    public static void main(String[] args) {
        Class c = null;
        try{
            c = Class.forName("com.t14.FancyToy");
        }catch (Exception e){
            System.out.println("Can not find FancyToy");
            System.exit(1);
        }
        printInfo(c);
        for (Class face :c.getInterfaces()){
            System.out.println(face);
        }
        Class up = c.getSuperclass();
        Object obj = null;
        try {
            obj = up.newInstance();
        }catch (InstantiationException e){
            System.out.println("Can not instantiate");
            System.exit(1);
        }catch (IllegalAccessException e){
            System.out.println("Can not access");
            System.exit(1);
        }
        printInfo(obj.getClass());
    }
    /**
     Class name: com.t14.FancyToy is interface? [false]
     Simple name: FancyToy
     Canonical name: com.t14.FancyToy
     interface com.t14.HasBatteries
     interface com.t14.Waterproof
     interface com.t14.Shoots
     Class name: com.t14.Tony is interface? [false]
     Simple name: Tony
     Canonical name: com.t14.Tony

     */
}
